<!DOCTYPE html>
<html>
    <head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">
    <title>蛋糕商城</title>
    <link rel='stylesheet' type='text/css' href='../easyui/themes/default/easyui.css'>
    <link rel='stylesheet' type='text/css' href='../easyui/themes/icon.css'>
    <link rel='stylesheet' type='text/css' href='../easyui/demo/demo.css'>
    <script type='text/javascript' src='../easyui/jquery.min.js'></script>
    <script type='text/javascript' src='../easyui/jquery.easyui.min.js'></script>
    <script type='text/javascript' src='../js/base64.js'></script>
    </head>
    <body  style="background:#B3DFDA;">
        <div  style="height: 100%;width: 100%;padding-top:60px">
        <center>
            <h2>蛋糕商城</h2><br/><br/>
            <img id="errorImg" src="/images/snake2.png"/>
            <div style="padding-top: 25px;color: red">
                <span style="font-size:24pt">出错了！</span><br/>
                <span id="errMsg" style="font-size:16pt"></span><br/>
                <span id="butBar"></span><input type="button" onclick="window.location.href='/login/index.html'" value="返回登录页面"/>
            </div>
        </center>
        </div>
    </body>
<script type="text/javascript">
var token = "";
if (window.localStorage.getItem("mytoken")) token = window.localStorage.getItem("mytoken");

$(document).ready(function() {
    $("#errorImg").attr("src","/images/snake2.png");
    outputMessage();
});

function outputMessage(){
    var message = getQueryStringByName("errorMessage");
    var jumpUrl = getQueryStringByName("jumpUrl");
    $("#errMsg").html(Base64.decode(message));
    if (jumpUrl) $("#butBar").html("<input type='button' value='返回' onclick='window.location.href=\""+Base64.decode(jumpUrl)+"?token="+token+"\"'/>");	
}

//获取QueryString的数组
function getQueryString(){
    location.search.match(new RegExp("[\?\&][^\?\&]+=[^\?\&]+","g"));
    if(result == null){
        return "";
    }

    for(var i = 0; i < result.length; i++){
        result[i] = result[i].substring(1);
    }
    return result;
}

//根据QueryString参数名称获取值
function getQueryStringByName(name){
    var result = location.search.match(new RegExp("[\?\&]" + name+ "=([^\&]+)","i"));
    if(result == null || result.length < 1){
        return "";
    }

    return result[1];
}

//根据QueryString参数索引获取值
function getQueryStringByIndex(index){
    if(index == null){
        return "";
    }

    var queryStringList = getQueryString();
    if (index >= queryStringList.length){
        return "";
    }

    var result = queryStringList[index];
    var startIndex = result.indexOf("=") + 1;
    result = result.substring(startIndex);
    return result;
}
</script>
</html>
